<!DOCTYPE html>



  


<html class="theme-next pisces use-motion" lang="zh-Hans">
<head><meta name="generator" content="Hexo 3.8.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">
















  
  
  <link href="/my_word/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css">







<link href="/my_word/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css">

<link href="/my_word/css/main.css?v=5.1.4" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="/my_word/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/my_word/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/my_word/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/my_word/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="搭建,">










<meta name="keywords" content="搭建">
<meta property="og:type" content="article">
<meta property="og:title" content="使用hexo和gitee搭建博客">
<meta property="og:url" content="http://hello_abc123.gitee.io/my_word/2019/01/02/hexo和gitee搭建博客及基本使用/index.html">
<meta property="og:site_name" content="Hexo">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="http://hello_abc123.gitee.io/my_word/2019/01/02/hexo和gitee搭建博客及基本使用/首图.jpg">
<meta property="og:image" content="http://hello_abc123.gitee.io/my_word/2019/01/02/hexo和gitee搭建博客及基本使用/新建仓库.png">
<meta property="og:image" content="http://hello_abc123.gitee.io/my_word/2019/01/02/hexo和gitee搭建博客及基本使用/开启gitee_pages服务.png">
<meta property="og:image" content="http://hello_abc123.gitee.io/my_word/2019/01/02/hexo和gitee搭建博客及基本使用/安装hexo框架.png">
<meta property="og:image" content="http://hello_abc123.gitee.io/my_word/2019/01/02/hexo和gitee搭建博客及基本使用/初始化.png">
<meta property="og:image" content="http://hello_abc123.gitee.io/my_word/2019/01/02/hexo和gitee搭建博客及基本使用/启动.png">
<meta property="og:image" content="http://hello_abc123.gitee.io/my_word/2019/01/02/hexo和gitee搭建博客及基本使用/预览.png">
<meta property="og:image" content="http://hello_abc123.gitee.io/my_word/2019/01/02/hexo和gitee搭建博客及基本使用/修改1.png">
<meta property="og:image" content="http://hello_abc123.gitee.io/my_word/2019/01/02/hexo和gitee搭建博客及基本使用/设置1.png">
<meta property="og:image" content="http://hello_abc123.gitee.io/my_word/2019/01/02/hexo和gitee搭建博客及基本使用/修改2.png">
<meta property="og:image" content="http://hello_abc123.gitee.io/my_word/2019/01/02/hexo和gitee搭建博客及基本使用/设置2.png">
<meta property="og:updated_time" content="2019-01-02T13:03:02.092Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="使用hexo和gitee搭建博客">
<meta name="twitter:image" content="http://hello_abc123.gitee.io/my_word/2019/01/02/hexo和gitee搭建博客及基本使用/首图.jpg">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/my_word/',
    scheme: 'Pisces',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://hello_abc123.gitee.io/my_word/2019/01/02/hexo和gitee搭建博客及基本使用/">





  <title>使用hexo和gitee搭建博客 | Hexo</title>
  





  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?6377c18acaee569095cb20cb684f00d4";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>




</head>

<body itemscope="" itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope="" itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/my_word/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Hexo</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/my_word/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br>
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/my_word/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br>
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/my_word/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br>
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/my_word/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>
            
            归档
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope="" itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://hello_abc123.gitee.io/my_word/my_word/2019/01/02/hexo和gitee搭建博客及基本使用/">

    <span hidden itemprop="author" itemscope="" itemtype="http://schema.org/Person">
      <meta itemprop="name" content="墨剑听禅">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/my_word/uploads/avatar.png">
    </span>

    <span hidden itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Hexo">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">使用hexo和gitee搭建博客</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-01-02T20:37:07+08:00">
                2019-01-02
              </time>
            

            

            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope="" itemtype="http://schema.org/Thing">
                  <a href="/my_word/categories/搭建/" itemprop="url" rel="index">
                    <span itemprop="name">搭建</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          
             <span id="/my_word/2019/01/02/hexo和gitee搭建博客及基本使用/" class="leancloud_visitors" data-flag-title="使用hexo和gitee搭建博客">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">阅读次数&#58;</span>
               
                 <span class="leancloud-visitors-count"></span>
             </span>
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p><img src="/my_word/2019/01/02/hexo和gitee搭建博客及基本使用/首图.jpg" alt=""><br><a id="more"></a></p>
<h1 id="搭建工作准备"><a href="#搭建工作准备" class="headerlink" title="搭建工作准备"></a>搭建工作准备</h1><p>1、安装git（用来将本地数据提交到gitee服务端）<a href="">查看链接</a></p>
<p>2、注册gitee账号<a href="https://gitee.com/" target="_blank" rel="noopener">查看链接</a></p>
<p>3、安装markdown软件(用来编写文章) <a href="">查看链接</a></p>
<h2 id="开始搭建"><a href="#开始搭建" class="headerlink" title="开始搭建"></a>开始搭建</h2><p>1、在gitee上新建一个仓库 如图：</p>
<p>   <img src="/my_word/2019/01/02/hexo和gitee搭建博客及基本使用/新建仓库.png" alt="新建仓库"></p>
<p>2、开启gitee pages服务以后就可以用这个地址作为你的博客地址 如图：</p>
<p>   <img src="/my_word/2019/01/02/hexo和gitee搭建博客及基本使用/开启gitee_pages服务.png" alt="开启gitee_pages服务"></p>
<p>3、安装hexo框架</p>
<ul>
<li><p>在一个目录下右键选择git bash here 输入命令：npm install -g hexo-cli  如图</p>
<p><img src="/my_word/2019/01/02/hexo和gitee搭建博客及基本使用/安装hexo框架.png" alt="安装hexo框架"></p>
<p>使用命令：hexo v 可以查看版本</p>
</li>
<li><p>初始化hexo</p>
<p>在本地任意你喜欢的合适位置创建博客本地文件夹（如：G:\搭建个人博客\My Blog） 右键选择git bash here  输入命令： hexo init 会生成以下文件 如图：</p>
<p><img src="/my_word/2019/01/02/hexo和gitee搭建博客及基本使用/初始化.png" alt="初始化"></p>
</li>
<li><p>验证是否成功： 输入命令 hexo s 来启动本地服务，再次ctrl+c停止本地服务 如图：</p>
<p><img src="/my_word/2019/01/02/hexo和gitee搭建博客及基本使用/启动.png" alt="启动"></p>
<p>浏览器进入localhost:4000预览本地博客</p>
<p><img src="/my_word/2019/01/02/hexo和gitee搭建博客及基本使用/预览.png" alt="预览"></p>
</li>
</ul>
<p>4、git配置同步gitee服务器（配置git全局信息，这样才能提交数据）</p>
<pre><code>在你创建的博客目录下右键选择git bash here 输入命令：

git confing --global user.name &quot;你的gitee用户名&quot;
git confing --global user.email &quot;你的gitee邮箱&quot;
</code></pre><ul>
<li><p>修改配置文件</p>
<p>在你创建的博客目录下找到 _config.yml配置文件</p>
<p>修改1—存放数据路径修改：如图：</p>
<p><img src="/my_word/2019/01/02/hexo和gitee搭建博客及基本使用/修改1.png" alt="修改1"></p>
<p>设置_config.yml的信息（url和root）信息如下 </p>
<p><img src="/my_word/2019/01/02/hexo和gitee搭建博客及基本使用/设置1.png" alt="设置1"></p>
<p>修改2—设置git路径：如图：</p>
<p><img src="/my_word/2019/01/02/hexo和gitee搭建博客及基本使用/修改2.png" alt="修改2"></p>
<p>设置_config.yml的信息（deploy）信息如下    </p>
<p><img src="/my_word/2019/01/02/hexo和gitee搭建博客及基本使用/设置2.png" alt="设置2"></p>
</li>
</ul>
<p>5、验证本地文件能否传输数据到gitee端</p>
<pre><code>1、安装hexo-deployer-git插件
在创建的博客目录下右键git bash here 输入命令： npm install hexo-deployer --save
2、输入命令 hexo g &amp;&amp;hexo d(上传到gitee)
3、查看仓库 看到文件有更新，就证明成功了
4、输入gitee pages的网址可以访问
</code></pre><h3 id="美化主题"><a href="#美化主题" class="headerlink" title="美化主题"></a>美化主题</h3><p>推荐使用next主题 使用教程<a href="">查看链接</a></p>
<h3 id="注意事项"><a href="#注意事项" class="headerlink" title="注意事项"></a>注意事项</h3><p>1、如果执行hexo g &amp;&amp;hexo d 命令时 弹出需要输入用户名和密码时 请复制粘贴</p>
<p>2、最好把SSH公钥填上 <a href="https://gitee.com/help/articles/4181#article-header0" target="_blank" rel="noopener">使用教程</a></p>
<hr>
<p>最后多谢基安的大佬<a href="http://zenggit.gitee.io/hexo/" target="_blank" rel="noopener">正常老司机</a>的教程</p>

      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/my_word/tags/搭建/" rel="tag"># 搭建</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/my_word/2019/01/02/9012家乡的雪/" rel="prev" title="9012家乡的雪">
                9012家乡的雪 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope="" itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image" src="/my_word/uploads/avatar.png" alt="墨剑听禅">
            
              <p class="site-author-name" itemprop="name">墨剑听禅</p>
              <p class="site-description motion-element" itemprop="description">不要在没有神的世界里祈祷神</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/my_word/archives/">
              
                  <span class="site-state-item-count">6</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/my_word/categories/index.html">
                  <span class="site-state-item-count">6</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/my_word/tags/index.html">
                  <span class="site-state-item-count">8</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a href="https://gitee.com/hello_abc123" target="_blank" title="Gitee">
                      
                        <i class="fa fa-fw fa-gitee"></i>Gitee</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://github.com/Tmory7" target="_blank" title="GitHub">
                      
                        <i class="fa fa-fw fa-github"></i>GitHub</a>
                  </span>
                
            </div>
          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#搭建工作准备"><span class="nav-number">1.</span> <span class="nav-text">搭建工作准备</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#开始搭建"><span class="nav-number">1.1.</span> <span class="nav-text">开始搭建</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#美化主题"><span class="nav-number">1.1.1.</span> <span class="nav-text">美化主题</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#注意事项"><span class="nav-number">1.1.2.</span> <span class="nav-text">注意事项</span></a></li></ol></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2019</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">墨剑听禅</span>

  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Pisces</a> v5.1.4</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/my_word/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/my_word/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/my_word/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/my_word/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/my_word/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/my_word/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/my_word/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/my_word/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/my_word/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/my_word/js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="/my_word/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/my_word/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/my_word/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  
  <script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.4.js"></script>
  <script>AV.initialize("Ix7CpM4QSDF37qDVq2z3ngJm-gzGzoHsz", "RT7QcsqT5bhU4nFcz498s5hA");</script>
  <script>
    function showTime(Counter) {
      var query = new AV.Query(Counter);
      var entries = [];
      var $visitors = $(".leancloud_visitors");

      $visitors.each(function () {
        entries.push( $(this).attr("id").trim() );
      });

      query.containedIn('url', entries);
      query.find()
        .done(function (results) {
          var COUNT_CONTAINER_REF = '.leancloud-visitors-count';

          if (results.length === 0) {
            $visitors.find(COUNT_CONTAINER_REF).text(0);
            return;
          }

          for (var i = 0; i < results.length; i++) {
            var item = results[i];
            var url = item.get('url');
            var time = item.get('time');
            var element = document.getElementById(url);

            $(element).find(COUNT_CONTAINER_REF).text(time);
          }
          for(var i = 0; i < entries.length; i++) {
            var url = entries[i];
            var element = document.getElementById(url);
            var countSpan = $(element).find(COUNT_CONTAINER_REF);
            if( countSpan.text() == '') {
              countSpan.text(0);
            }
          }
        })
        .fail(function (object, error) {
          console.log("Error: " + error.code + " " + error.message);
        });
    }

    function addCount(Counter) {
      var $visitors = $(".leancloud_visitors");
      var url = $visitors.attr('id').trim();
      var title = $visitors.attr('data-flag-title').trim();
      var query = new AV.Query(Counter);

      query.equalTo("url", url);
      query.find({
        success: function(results) {
          if (results.length > 0) {
            var counter = results[0];
            counter.fetchWhenSave(true);
            counter.increment("time");
            counter.save(null, {
              success: function(counter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(counter.get('time'));
              },
              error: function(counter, error) {
                console.log('Failed to save Visitor num, with error message: ' + error.message);
              }
            });
          } else {
            var newcounter = new Counter();
            /* Set ACL */
            var acl = new AV.ACL();
            acl.setPublicReadAccess(true);
            acl.setPublicWriteAccess(true);
            newcounter.setACL(acl);
            /* End Set ACL */
            newcounter.set("title", title);
            newcounter.set("url", url);
            newcounter.set("time", 1);
            newcounter.save(null, {
              success: function(newcounter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(newcounter.get('time'));
              },
              error: function(newcounter, error) {
                console.log('Failed to create');
              }
            });
          }
        },
        error: function(error) {
          console.log('Error:' + error.code + " " + error.message);
        }
      });
    }

    $(function() {
      var Counter = AV.Object.extend("Counter");
      if ($('.leancloud_visitors').length == 1) {
        addCount(Counter);
      } else if ($('.post-title-link').length > 1) {
        showTime(Counter);
      }
    });
  </script>



  

  

  
  

  

  

  

</body>
</html>
